
-module(amqp_client_sup).

-behaviour(supervisor2).

%% API
-export([start_link/0, start_connection_sup/1]).

%% Supervisor callbacks
-export([init/1]).

%% Helper macro for declaring children of supervisor
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).

%% ===================================================================
%% API functions
%% ===================================================================

start_link() ->
    supervisor2:start_link({local, ?MODULE}, ?MODULE, []).

start_connection_sup(AmqpParams) ->
    supervisor2:start_child(amqp_client_sup, [AmqpParams]).
%% ===================================================================
%% Supervisor callbacks
%% ===================================================================

init([]) ->
    {ok, {{simple_one_for_one_terminate, 0, 1},
          [{connection_sup, {amqp_connection_sup, start_link, []},
	    temporary, infinity, supervisor, [amqp_connection_sup]}]}}.

